package com.exam.api.modules.system.controller.manager;

import cn.dev33.satoken.annotation.SaCheckLogin;

import com.exam.api.common.web.TinyResponse;
import com.exam.api.modules.system.domain.TblRole;
import com.exam.api.modules.system.dto.RoleAddDTO;
import com.exam.api.modules.system.dto.RoleIdDTO;
import com.exam.api.modules.system.dto.RolePageDTO;
import com.exam.api.modules.system.dto.RoleUpdateDTO;
import com.exam.api.modules.system.service.TblRoleService;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * (管理端) 角色相关接口
 *
 * @author bcheng
 */
@Tag(name = "(管理端) 角色相关接口", description = "(管理端) 角色相关接口")
@RestController
@RequestMapping("/manager/role")
@SaCheckLogin
@TinyResponse
public class RoleManagerController {

    @Resource
    private TblRoleService tblRoleService;

    @Operation(summary = "角色分页列表", description = "角色分页列表")
    @PostMapping("/page")
    public Page<TblRole> pageRole(@RequestBody @Validated RolePageDTO dto) {
        return tblRoleService.pageRole(dto);
    }

    @Operation(summary = "角色信息", description = "角色信息")
    @PostMapping("/info")
    public TblRole getRole(@RequestBody @Validated RoleIdDTO dto) {
        return tblRoleService.getRole(dto);
    }

    @Operation(summary = "新增角色", description = "新增角色")
    @PostMapping("/add")
    public void addRole(@RequestBody @Validated RoleAddDTO dto) {
        tblRoleService.addRole(dto);
    }

    @Operation(summary = "更新角色", description = "更新角色")
    @PostMapping("/update")
    public void updateRole(@RequestBody @Validated RoleUpdateDTO dto) {
        tblRoleService.updateRole(dto);
    }

    @Operation(summary = "删除角色", description = "删除角色")
    @PostMapping("/delete")
    public void deleteRole(@RequestBody @Validated RoleIdDTO dto) {
        tblRoleService.deleteRole(dto);
    }
}
